package com.guigu.xm.wp.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.xm.pojo.*;
import com.guigu.xm.wp.mapper.SCellMapper;
import com.guigu.xm.wp.mapper.SGatherMapper;
import com.guigu.xm.wp.mapper.SPayMapper;
import com.guigu.xm.wp.service.AddScellService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddScellServlet implements AddScellService {

    @Autowired(required = false)
    SCellMapper mapper;

    @Autowired(required = false)
    SGatherMapper sGatherMapper;

    @Autowired(required = false)
    SPayMapper sPayMapper;
    @Override
    public int add(SCell sCell) {
        return mapper.insert(sCell);
    }

    @Override
    public SCell selectPid(SCell name) {
        return mapper.selectPid(name);
    }

    @Override
    public int del(String name) {
        return mapper.delPid(name);
    }

    @Override
    public int updateCell(SCell sCell) {
        return mapper.updateByPrimaryKey(sCell);
    }

    @Override
    public int addRk(SGather sGather) {
        return sGatherMapper.insert(sGather);
    }

    @Override
    public PageVo<SGather> query(int page, int num,SGather sGather) {
        PageHelper.startPage(page,num);
        List<SGather> sGathers = sGatherMapper.queryAll(sGather);
        PageInfo info=new PageInfo(sGathers);
        PageVo pageVo=new PageVo<SGather>();
        pageVo.setRows(sGathers);
        pageVo.setTotal(info.getTotal());
        return pageVo;
    }

    @Override
    public int update(SGather sGather) {
        return sGatherMapper.update(sGather);
    }

    @Override
    public int updatePid(SGather sGather) {
        return sGatherMapper.updatePid(sGather);
    }

    @Override
    public int addCk(SPay sGather) {
        return sPayMapper.insert(sGather);
    }

    @Override
    public PageVo<SPay> queryCk(int page, int num, SPay sGather) {
        PageHelper.startPage(page,num);
        List<SPay> sGathers = sPayMapper.queryAll(sGather);
        PageInfo info=new PageInfo(sGathers);
        PageVo pageVo=new PageVo<SPay>();
        pageVo.setRows(sGathers);
        pageVo.setTotal(info.getTotal());
        return pageVo;
    }

    @Override
    public int updateCk(SPay sGather) {
        return sPayMapper.updateCk(sGather);
    }

    @Override
    public int updateCkPid(SPay sGather) {
        return sPayMapper.updateCkPid(sGather);
    }


}
